package com.springboot.utils;

import com.springboot.enums.CodeEnum;
import lombok.Data;

@Data
public class ResultUtil {
    private int code;
    private String msg;
    private Object data;

    public ResultUtil() {
    }

    public ResultUtil(int code, String msg, Object data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    public static ResultUtil Code (int code, String msg, Object data){
        return new ResultUtil(code,msg,data);
    }

    public static ResultUtil Success (){
        return new ResultUtil(CodeEnum.SUCCESS.getCode(),CodeEnum.SUCCESS.getMessage(),"");
    }

    public static ResultUtil Success (Object data){
        return new ResultUtil(CodeEnum.SUCCESS.getCode(),CodeEnum.SUCCESS.getMessage(),data);
    }

    public static ResultUtil Success (String msg,Object data){
        return new ResultUtil(CodeEnum.SUCCESS.getCode(),msg,data);
    }

    public static ResultUtil Error (){
        return new ResultUtil(CodeEnum.SUCCESS.getCode(),CodeEnum.SUCCESS.getMessage(),"");
    }

    public static ResultUtil Error (String msg){
        return new ResultUtil(CodeEnum.ERROR.getCode(),msg,"");
    }

    public static ResultUtil Error (Object data){
        return new ResultUtil(CodeEnum.ERROR.getCode(),CodeEnum.SUCCESS.getMessage(),data);
    }

    public static ResultUtil Error (String msg,Object data){
        return new ResultUtil(CodeEnum.ERROR.getCode(),msg,data);
    }


}
